package com.cyj.crm02.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("crm_employee")
public class Employee extends BaseEntity{
    @TableId(type = IdType.AUTO)
    private Integer employeeId;
    private String employeeName;
    private String password;
    private String salt;
    private Integer sex;
    private Integer age;
    private String phone;
    private String address;

    @TableField(exist = false)
    private List<Role> roles;


    /**
     *  真实盐 =用户名 + 盐
     */
    public String getCredentialsSalt(){
        return employeeName + salt;
    }

    @Override
    public String toString() {
        return "Employee{" +
                "employeeId=" + employeeId +
                ", employeeName='" + employeeName + '\'' +
                ", password='" + password + '\'' +
                ", salt='" + salt + '\'' +
                ", sex=" + sex +
                ", age=" + age +
                ", phone='" + phone + '\'' +
                ", address='" + address + '\'' +
                ", roles=" + roles +
                '}';
    }
}
